import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import NProgress from 'plugins/nprogress'
import Layout from '../layout/Index.vue'
import { routers } from './routers.js'

const router = createRouter({
    history: createWebHistory(), //yreateWebHashHistory(),
    routes: [
        {
            path: '/',
            component: Layout,
            redirect: { name: 'index' },
            children: routers,
        },
        {
            path: '/login',
            name: 'login',
            component: () => import('views/login.vue'),
        },
    ],
})
router.beforeEach((to, from, next) => {
    NProgress.start()
    next()
})

router.afterEach(() => {
    NProgress.done()
})

export default router
